
/**
 * Copyright 2009 cestum.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
package org.waveprotocol.wave.model.document.operation.automaton {
import org.goverla.collections.ArrayList;
import org.waveprotocol.wave.model.document.operation.automaton.enums.PermittedCharacters;

/**
 * Allows queries on what the XML schema allows.
 */
public interface DocumentSchema {
  /**
   * True iff childType elements are permitted to occur as children of parentTypeOrNull,
   * or at the top level if parentTypeOrNull is null.
   *
   * @param parentTypeOrNull an XML name or null.
   * @param childType an XML name.
   */
  function permitsChild(parentTypeOrNull:String, childType:String):Boolean ;

  /**
   * What type of text is permitted within elements of type typeOrNull, or
   * at the top level if typeOrNull is null.
   *
   * @param typeOrNull an XML name.
   */
  function permittedCharacters(typeOrNull:String):PermittedCharacters ;

  /**
   * True iff elements of type type permit an attribute named attributeName.
   *
   * @param type an XML name.
   * @param attributeName an XML name.
   */
  function permitsAttribute1(type:String, attributeName:String):Boolean ;

  /**
   * True iff elements of type type permit an attribute named attributeName
   * with the value attributeValue.
   *
   * @param type an XML name.
   * @param attributeName an XML name.
   * @param attributeValue a string.
   */
  function permitsAttribute2(type:String, attributeName:String, attributeValue:String):Boolean ;

  /**
   * Returns a list of tag names of elements that must always occur in the given
   * order at the start of the given type.
   *
   * @param typeOrNull
   * @return list of required initial elements (may be empty)
   */
  function getRequiredInitialChildren(typeOrNull:String):ArrayList ;

}
}